from sklearn.cluster import KMeans
import numpy as np

data, n = [], 16
for i in range(n):
    data.append(np.loadtxt(f"data-{i}.csv", delimiter=","))
data = np.concatenate(data)
print(data.shape)

# traj = data.reshape(-1, 7, 2)
# plt.figure(figsize=(10, 10))  # Create a new figure with a specific size
# for i in range(traj.shape[0]):  # Loop over the number of trajectories
#     trajectory =traj[i]  # Get the i-th trajectory
#     plt.plot(trajectory[:, 0], trajectory[:, 1])  # Plot the trajectory

# plt.axis("equal")  # Set the aspect ratio of the plot to be equal
# plt.show()  # Display the figure

kmeans = KMeans(n_clusters=16, random_state=0).fit(data)
np.savetxt(f'cluster.txt', kmeans.cluster_centers_, delimiter=',')